#include<iostream> 
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
private:
	static bool cmp(vector<int> &a, vector<int> &b){
		if(a[0] != b[0]){
			return a[0] < b[0];
		}
		return a[1] > b[1];
	}	
public:
    vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
		sort(people.begin(), people.end(), cmp);
		vector<vector<int>> ans = vector<vector<int>>(people.size(), vector<int>(2, 0));
		for(int i = 0; i < people.size(); i++){
			int step = people[i][1] + 1;
			for(int j = 0; j < ans.size(); j++){
				if(!step && !ans[i][0]){
					ans[i][0] = people[i][0];
					ans[i][1] = people[i][1];
				}
				else if(ans[i][0]){
					continue;
				}
				step--;
			}
		}
		return ans;
    }
};

int main(){
	return 0;
}
